/*
2021-8-8
https://leetcode-cn.com/problems/remove-stones-to-minimize-the-total/
*/
class Solution {
public:
    int minStoneSum(vector<int>& piles, int k) {
    
        priority_queue<int> heap;
        for(auto t:piles)
        {
            heap.push(t);
        }
        for(int i=0;i<k;i++)
        {
            int t=heap.top();
            heap.pop();
            heap.push((t+1)/2);
        }
        int res=0;
        while(heap.size())
        {
            int t=heap.top();
            heap.pop();
            res+=t;
        }
        return res;
    }
};
